const sql = require("../../config/config");

// 获取parts
function getParts() {
  return sql("select * from carousel");
}

// 添加parts
function addParts(arr) {
  return sql("insert into carousel value (NULL,?,?,?,?,?,1,?)", arr);
}

// 更新parts
function updateParts(arr) {
  return sql("update carousel set title = ? , price = ? , src = ? , url = ? , atime = ? where parts_id = ?", arr);
}

// 删除parts
function deleteParts(arr) {
  return sql("delete from carousel where parts_id = ?", arr);
}

// 是否展示parts
function showParts(arr) {
  return sql("update carousel set isShow = ? where parts_id = ?", arr);
}

// 批量删除
function batchDelete(arr) {
  return sql("delete from carousel where parts_id in(?)",arr);
}

module.exports = {
  getParts,
  addParts,
  updateParts,
  deleteParts,
  showParts,
  batchDelete
};
